#pragma once
#include <string>
#include <memory>
#include <pthread.h>
#include <functional>
#include "Noncopyable.h"
#include "Mutex.h"

namespace utils
{

class Thread
{
public:
    using ptr = std::shared_ptr<Thread>;

    Thread(std::function<void()> task, const std::string& name = "");
    ~Thread();
    void join();

    static unsigned long int getId();
    static std::string getName();

private:
    static void* run(void* arg);

private:
    std::string m_strName;
    pthread_t m_id;
    std::function<void()> m_task;
    Mutex m_mutex;
    Semaphore m_sem;
};
    
} // namespace utils
